<%@ page contentType="text/html; charset=UTF-8" %>
<%@page import="com.infomanage.enums.*"%>
<%@page import="com.infomanage.service.hr.*"%>
<%@page import="com.infomanage.po.*" %>
<%@page import="com.infomanage.vo.*" %>
<%@page import="java.util.*" %>
<%  response.addDateHeader("Expires", 0);response.setHeader("Pragma","no-cache"); response.setHeader("Cache-Control","no-cache");%>
<%
	String personId = request.getParameter("personId");
	if(personId == null) personId = "";
	List<PersonResumeInfoItem> items = PersonManageService.loadPersonResumeInfo(request, response, out);
%>
<html>
<head>
	<title>个人简历</title>
	<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<link href="../../css/table.css" rel="stylesheet" type="text/css">
	<link href="../../css/calendar.css" rel="stylesheet" type="text/css">
	<link href="../../css/webTree.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="../../js/calendar.js"></script>
	<script type="text/javascript">
	   function init() {
	   }

	   // 添加
	   function addItem(obj){
		  var eduTable = document.getElementById("eduTable");
		  var rowCount = eduTable.rows.length;
	      var newRow = eduTable.insertRow();
	      var newCell = null;
	      var lastRow = eduTable.rows(rowCount - 1);
	      var cells = lastRow.cells;
	      for(var i = 0; i < cells.length; i++){
	    	  newCell = newRow.insertCell();
	    	  newCell.innerHTML = cells[i].innerHTML;
		  }
	      newRow.loc = parseFloat(lastRow.loc) + 1;

		  var newCells = newRow.cells;
		  for(var i = 0; i < newCells.length; i++){
			var childNode = null;
			var name = null;
			var id = null;
			for(var j = 0; j < newCells[i].childNodes.length; j++){
				childNode = newCells[i].childNodes[j];
				name = childNode.name;
				if(name && name != ""){
					name = name.split("_")[0];
					name += "_" + newRow.loc;
					childNode.name = name;
			    }
				id = childNode.id;
				if(id && id != ""){
					id = id.split("_")[0];
					id += "_" + newRow.loc;
					childNode.id = id;
				}
			}
	      }
		  newCells[newCells.length - 1].align = "center";
	   }

	   // 删除
	   function delItem(obj){
		   var rowObj = obj.parentNode.parentNode;
		   if(rowObj.loc == "0"){
		  	  var cells = rowObj.cells;
		  	  for(var i = 0; i < cells.length; i++){
				  for(var j = 0; j < cells[i].childNodes.length; j++){
						childNode = cells[i].childNodes[j];
						try{
							childNode.value="";
						}catch(e){};
				  }
		      }
			  return;
		   }

		   var eduTable = document.getElementById("eduTable");
		   var currIndex = -1;
		   var rows = eduTable.rows;
		   for(var i = 0; i < rows.length; i++){
			   if(rows[i].loc && rows[i].loc == rowObj.loc){
				   currIndex = i;
				   break;
			   }
		   }
		   if(currIndex != -1){
			   eduTable.deleteRow(currIndex);
		   }
		   //eduTable.deleteRow(parseFloat(rowObj.loc) + 2);// 2:图标行和表头行
	   }

	   // 保存
	   function save(){
	   	   infoForm.personId.value = parent.personGenerateId;
	       infoForm.rows.value = eduTable.rows.length - 2;
		   infoForm.submit(); 
	   }
	</script>
</head>
<body  rightmargin="0" bottommargin="0" leftmargin="0" topmargin="0" style="overflow: auto;">
	<form name="infoForm" action="personManage_action.jsp" target="actionFrame" method="get">
	<input type="hidden" name="infoType" value="eduInfo">
	<input type="hidden" name="actionType" value="resumeSave">
	<input type="hidden" name="rows" value="">
    <input type="hidden" name="personId" value="">
	<table id="eduTable" class="personDataTable" style="width: 100%;" cellpadding="0" cellspacing="0">
		<col width="55%">
		<col width="25%">
		<col width="17%">
		<col width="3%">
		<tr height="10px">
			<td colspan="4" align="right" style="padding-right: 22px;">
				<a href="#" onclick="save();">
					<img border="0" title="保存个人简历" src="../../img/btn_save.gif" style="cursor: hand;">
				</a>
			</td>
		</tr>
		<tr height="23px"  class="personEduTableHeader">
			<td>
				起止时间
			</td>
			<td>
				工作单位
			</td>
			<td>
				职务(工种)
			</td>
			<td>
				&nbsp;
			</td>
		</tr>
		<%
			if(items == null){
		%>
		<tr loc="0">
			<td>
				<input calendar="true" type="text" style="width: 220;cursor: hand;" name="startTime_0" id="startTime_0" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
									src="../../img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar(this.previousSibling.id, 'y-mm-dd');">
				&nbsp;&nbsp;至&nbsp;&nbsp;
				<input calendar="true" type="text" style="width: 220;cursor: hand;" name="endTime_0" id="endTime_0" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
									src="../../img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar(this.previousSibling.id, 'y-mm-dd');">
			</td>
			<td>
				<input type="text" name="company_0">
			</td>
			<td>
				<input name="job_0" type="text">
			</td>
			<td  align="center">
				<a href="#" title="删除" onclick="delItem(this);"><img src="../../img/dot_sc.gif" border="0"></a>
			</td>
		</tr>
	   <%		
			}else{
				for(int i = 0; i < items.size(); i++){
					PersonResumeInfoItem item = items.get(i);
		%>	
		<tr loc="<%=i%>">
			<td>
				<input value="<%=item.getStartTime() %>" calendar="true" type="text" style="width: 220;cursor: hand;" name="startTime_<%=i%>" id="startTime_0" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
									src="../../img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar(this.previousSibling.id, 'y-mm-dd');">
				&nbsp;&nbsp;至&nbsp;&nbsp;
				<input value="<%=item.getEndTime() %>" calendar="true" type="text" style="width: 220;cursor: hand;" name="endTime_<%=i%>" id="endTime_0" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
									src="../../img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar(this.previousSibling.id, 'y-mm-dd');">
			</td>
			<td>
				<input value="<%=item.getCompany() %>" type="text" name="company_<%=i%>">
			</td>
			<td>
				<input value="<%=item.getJob() %>" name="job_<%=i%>" type="text">
			</td>
			<td  align="center">
				<a href="#" title="删除" onclick="delItem(this);"><img src="../../img/dot_sc.gif" border="0"></a>
			</td>
		</tr>
				<%	
				 }
			}
		%>
	</table>
	<img onclick="addItem(this);" style="cursor: hand;" src="../../img/btn_addcontinue.gif" border="0" title="继续添加个人简历"/>
	</form>
	<iframe src="#" name="actionFrame" style="display: none;"></iframe>
</body>
</html>